/**
* @ProjectName: ShopSytem
* @Title: GetGoodDetail.java 
* @Package com.element5th.shop.servlet.good 
* @Description: 查看商品详细信息
* @author 第五元素小组   
* @date 2012-10-26 16:41:26 
* @version V1.0   
*/
package com.element5th.shop.servlet.good;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.element5th.shop.comm.DaoFactory;
import com.element5th.shop.dao.good.IGoodDao;
import com.element5th.shop.dto.BaseDto;

/**
 * Servlet implementation class GetGoodDetail
 */
@WebServlet({"/good_detail", "/page/admin/page/good_detail"})
public class GetGoodDetail extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int goodId = Integer.parseInt(request.getParameter("goodId"));
		BaseDto dto = new BaseDto();
		dto.getGoodDetail().setGoodId(goodId);
		
		IGoodDao dao = DaoFactory.getGoodDao();
		dto = dao.getGoodDetail(dto);
		
		request.setAttribute("dto", dto);
		
		String path = null;
		
		if(request.getRequestURI().indexOf("admin") > -1)
			path = "/page/admin/page/good_detail.jsp";
		else
			path = "/page/good_detail.jsp";
		
		this.getServletContext().getRequestDispatcher(path).forward(request, response);
	}

}
